package cn.c4ad.voa;

import android.app.ActionBar;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

public class MainActivity extends FragmentActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_activity);

		FragmentTabHost fragmentTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
		fragmentTabHost.setup(this, getSupportFragmentManager(),
				R.id.maincontent);

		View indicator;
		ImageView indicatorImg;
		TextView indicatorText;
		TabSpec spec;

		// indicator = (TextView) View.inflate(this,
		// R.layout.main_activity_indicator, null);
		// indicator.setCompoundDrawablesWithIntrinsicBounds(0,
		// R.drawable.ic_local, 0, 0);
		// indicator.setText(R.string.ic_local);
		// spec =
		// fragmentTabHost.newTabSpec(LocalFragment.class.getSimpleName()).setIndicator(
		// indicator);
		// fragmentTabHost.addTab(spec, LocalFragment.class, null);

		indicator = View.inflate(this, R.layout.main_activity_indicator, null);
		indicatorImg = (ImageView) indicator.findViewById(R.id.indicator_ic);
		indicatorImg.setImageResource(R.drawable.ic_list);
		indicatorText = (TextView) indicator.findViewById(R.id.indicator_text);
		indicatorText.setText(R.string.ic_special);
		spec = fragmentTabHost.newTabSpec(ListFragment.class.getSimpleName())
				.setIndicator(indicator);
		fragmentTabHost.addTab(spec, ListFragment.class, null);
		
		indicator = View.inflate(this, R.layout.main_activity_indicator, null);
		indicatorImg = (ImageView) indicator.findViewById(R.id.indicator_ic);
		indicatorImg.setImageResource(R.drawable.ic_standard);
		indicatorText = (TextView) indicator.findViewById(R.id.indicator_text);
		indicatorText.setText(R.string.ic_standard);
		spec = fragmentTabHost.newTabSpec(StandardListFragment.class.getSimpleName())
				.setIndicator(indicator);
		fragmentTabHost.addTab(spec, StandardListFragment.class, null);
		
		indicator = View.inflate(this, R.layout.main_activity_indicator, null);
		indicatorImg = (ImageView) indicator.findViewById(R.id.indicator_ic);
		indicatorImg.setImageResource(R.drawable.ic_statistic);
		indicatorText = (TextView) indicator.findViewById(R.id.indicator_text);
		indicatorText.setText(R.string.ic_statistic);
		spec = fragmentTabHost.newTabSpec(StatisticFragment.class.getSimpleName())
				.setIndicator(indicator);
		fragmentTabHost.addTab(spec, StatisticFragment.class, null);

		// indicator = (TextView) View.inflate(this,
		// R.layout.main_activity_indicator, null);
		// indicator.setCompoundDrawablesWithIntrinsicBounds(0,
		// R.drawable.ic_download, 0, 0);
		// indicator.setText(R.string.ic_download);
		// spec =
		// fragmentTabHost.newTabSpec(DownloadFragment.class.getSimpleName()).setIndicator(
		// indicator);
		// fragmentTabHost.addTab(spec, DownloadFragment.class, null);

		indicator = View.inflate(this, R.layout.main_activity_indicator, null);
		indicatorImg = (ImageView) indicator.findViewById(R.id.indicator_ic);
		indicatorImg.setImageResource(R.drawable.ic_about);
		indicatorText = (TextView) indicator.findViewById(R.id.indicator_text);
		indicatorText.setText(R.string.ic_about);
		spec = fragmentTabHost.newTabSpec(AboutFragment.class.getSimpleName())
				.setIndicator(indicator);
		fragmentTabHost.addTab(spec, AboutFragment.class, null);

		fragmentTabHost.getTabWidget().setBackgroundResource(
				R.drawable.bg_bottom_bar);

		ActionBar actionBar = getActionBar();
		actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
		actionBar.setCustomView(R.layout.main_activity_action_bar);
	}
}
